//
//  HeaderView.m
//  FlowerRainGround
//
//  Created by zfc on 16/4/20.
//  Copyright © 2016年 lanou. All rights reserved.
//

#import "HeaderView.h"
#import "AddUserViewController.h"
#import "CommunityViewController.h"


@implementation HeaderView


- (IBAction)find:(UIButton *)sender {

    UIButton *button1 = [self viewWithTag:1000];
    [button1 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    UIImageView *imageView1 = [self viewWithTag:2000];
    imageView1.backgroundColor = [UIColor lightGrayColor];
    
    UIButton *button2 = [self viewWithTag:1001];
    [button2 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    UIImageView *imageView2 = [self viewWithTag:2001];
    imageView2.backgroundColor = [UIColor lightGrayColor];
    
    UIButton *button3 = [self viewWithTag:1002];
    [button3 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    UIImageView *imageView3 = [self viewWithTag:2002];
    imageView3.backgroundColor = [UIColor lightGrayColor];
    
    UIButton *button4 = [self viewWithTag:1003];
    [button4 setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
    UIImageView *imageView4 = [self viewWithTag:2003];
    imageView4.backgroundColor = [UIColor lightGrayColor];
    
    
    [sender setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
    UIImageView *imageView = [self viewWithTag:sender.tag + 1000];
    imageView.backgroundColor = [UIColor orangeColor];
    
    if (self.SendButton) {
        self.SendButton(sender);
    }
   
}

- (IBAction)search:(id)sender {

    AddUserViewController *addUserVC = [[AddUserViewController alloc] init];
    UINavigationController *naVC = (UINavigationController *)[self navigationController];

    [naVC pushViewController:addUserVC animated:YES];
}

- (IBAction)collect:(id)sender {
//    if ([[self viewController] class] == [CommunityViewController class]) {
//        <#statements#>
//    }
    
    
}

//点击button的时候跳转到控制器上，通过响应者找到这个控制器
- (UIViewController *)viewController {
    for (UIView *next = [self superview]; next; next = next.superview) {
        UIResponder *nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]]) {
            return (UIViewController *)nextResponder;
        }
    }
    return nil;
}


- (UIViewController *)navigationController {
    for (UIView *next = [self superview]; next; next = next.superview) {
        UIResponder *nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UINavigationController class]]) {
            return (UINavigationController *)nextResponder;
        }
    }
    return nil;
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
